<template>
  <el-dialog :visible.sync="isShowDelete" v-loading="loading">
    <div>
        <label for="">请输入删除原因:</label>
      <el-input type="textarea" v-model="reason"></el-input>
    </div>
    <div  class="mt">
        <label for="">请上传辅助文档：</label>
      <input @change="fileChange" type="file" name="file" ref="upFiles" id="upFiles"/>
    </div>
    <div class="mt">
      <el-button type="primary" @click="onSubmit">提交</el-button>
      <el-button @click="cancle">取消</el-button>
    </div>
  </el-dialog>
</template>

<script>
const queryString = require('querystring')
import { FileChange } from "utils/formData";
export default {
  name: 'deleteInfo',
  data() {
      return {
          reason: '',
          files: '',
          loading: false
      }
  },
  props: ['id', 'isShowDelete'],
  methods: {
      onSubmit() {
          const params = {
              reason: this.reason,
              files: this.files
          }
          this.axios.delete(`/order/${this.id}?` + queryString.stringify(params)).then(res => {
                // this.search();
                this.$message(res.data.data)
                this.isShowDelete = false
            }).catch(err => {
                // this.$message(err.statusText)
            })
      },
      cancle() {
          this.isShowDelete = false
      },
      fileChange(e) {
            this.loading = true;
            FileChange(e, (res) => {
                this.loading = false;
                this.files = res.url;
            })
      },
      upAction() {
        //   debugger 
          this.$refs.upFiles.focus()
          document.getElementById('upFiles').focus()
      }
  },
  watch: {
      isShowDelete() {
          this.reason = ''
          this.files = ''
          document.getElementById('upFiles').value = ''
      }
  }

};
</script>

<style scoped>
.mt{
    margin-top: 30px
}
</style>
